package com.nCoV.EpidemicSurveillance.scheduled;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nCoV.EpidemicSurveillance.common.utils.DateUtil;
import com.nCoV.EpidemicSurveillance.common.utils.ListUtil;
import com.nCoV.EpidemicSurveillance.repository.PersonRepository;


/**
 * @author 罗穆健
 * @date 2020年4月21日
 */
@Service
public class Sjfx {

	@Autowired
	PersonRepository personRepository;
	Logger logger;
	int qfq = 14;//14天潜伏期
	Double grgl1;//感染概率
	Double grgl2;
	Double grgl1Temp;
	Double grgl2Temp;
	Double age1;//年龄 概率
	Double age2;
	Double jcNum1;//检测次数 概率
	Double jcNum2;
	Double jcbNum1;
	Double jcbNum2;//基础病
	Double tfqk;//通风
	Double duration;//时长
	Double jclx;//接触类型
	Double kz1;
	Double kz2;//口罩
	Double rAgrgl;
	Double rBgrgl;
	Double pA;//没考虑对面感染概率的概率
	Double pB;
	public void sjcl() {
		
		List<Map<String, Object>> sjclList = new ArrayList<Map<String,Object>>();
		sjclList=personRepository.getAllList();
		ListUtil.ListSort(sjclList, "RcontactTime");//根据时间从小到大排序
		try {
			
			for (Map<String, Object> map : sjclList) {
				//选择14天内的接触关系
				if((DateUtil.dateDiff(DateUtil.MyStringToDate(map.get("RcontactTime").toString()), new Date())<qfq*24*60*60*1000) &&
						(map.get("sfxyjs")==null || "".equals(map.get("sfxyjs").toString()) || "true".equals(map.get("sfxyjs").toString()))) {
					
					dingLiang(map);
						
					pA = (1.0-kz1)*age1*jcNum2*jcbNum1*tfqk*duration*jclx;
					pB = (1.0-kz2)*age2*jcNum1*jcbNum2*tfqk*duration*jclx;
					Double RaGl = 0.0;//a节点关系上的这时刻的概率
					Double RbGl = 0.0;//b节点关系上的这时刻的概率
					Double aGl = null;//a节点这时刻的概率
					Double bGl = null;//b节点这时刻的概率
					Double grglA = grgl1;
					Double grglB = grgl2;
					Double rAgrglTemp = rAgrgl;//这两个变量用于保存关系上的概率，主要用于后续的概率叠加
					Double rBgrglTemp = rBgrgl;
					//获取在计算新插入的节点时，双方的概率，因为本身节点的概率是已经与很多节点计算之后了的。
					for (Map<String, Object> map1 : sjclList) {
						Double aGlTemp = null;
						Double cGlTemp = null;
						if((DateUtil.dateDiff(DateUtil.MyStringToDate(map1.get("RcontactTime").toString()), new Date())<qfq*24*60*60*1000) &&
								(DateUtil.compareDate(map1.get("RcontactTime").toString(), map.get("RcontactTime").toString()))) {
							if(map.get("AId").toString().equals(map1.get("AId").toString())) {
								aGlTemp = Double.parseDouble(map1.get("RAgrgl").toString());
								if(aGlTemp > RaGl) {
									dingLiang(map1);
									RaGl = aGlTemp;
									aGl = 1.0-(1.0-rAgrgl)*(1.0-(1.0-kz1)*age1*jcNum2*jcbNum1*tfqk*duration*jclx*rBgrgl);	
								}
							}
							if(map.get("AId").toString().equals(map1.get("BId").toString())) {
								aGlTemp = Double.parseDouble(map1.get("RBgrgl").toString());
								if(aGlTemp > RaGl) {
									dingLiang(map1);
									RaGl = aGlTemp;
									aGl = 1.0-(1.0-rBgrgl)*(1.0-(1.0-kz2)*age2*jcNum1*jcbNum2*tfqk*duration*jclx*rAgrgl);	
								}
							}
							
							if(map.get("BId").toString().equals(map1.get("AId").toString())) {
								cGlTemp = Double.parseDouble(map1.get("RAgrgl").toString());
								if(cGlTemp > RbGl) {
									dingLiang(map1);
									RbGl = cGlTemp;
									bGl = 1.0-(1.0-rAgrgl)*(1.0-(1.0-kz1)*age1*jcNum2*jcbNum1*tfqk*duration*jclx*rBgrgl);	
								}
							}
							if(map.get("BId").toString().equals(map1.get("BId").toString())) {
								cGlTemp = Double.parseDouble(map1.get("RBgrgl").toString());
								if(cGlTemp > RbGl) {
									dingLiang(map1);
									RbGl = cGlTemp;
									bGl = 1.0-(1.0-rBgrgl)*(1.0-(1.0-kz2)*age2*jcNum1*jcbNum2*tfqk*duration*jclx*rAgrgl);	
								}
							}
						}
					}
					
					if(aGl == null) {
						if(map.get("RAgrgl") == null || "".equals(map.get("RAgrgl").toString())) {
							aGl = 0.0;
						} else {
							aGl = Double.parseDouble(map.get("RAgrgl").toString());
						}
						
					}
					if(bGl == null) {
						if(map.get("RBgrgl") == null || "".equals(map.get("RBgrgl").toString())) {
							bGl = 0.0;
						} else {
							bGl = Double.parseDouble(map.get("RBgrgl").toString());
						}
					}
					grgl1 = 1.0 - (1.0-grglA)*(1.0-bGl*pA);					
					grgl2 = 1.0 - (1.0-grglB)*(1.0-aGl*pB);
					map.put("sfxyjs", "false");//下次不需要计算
					map.put("shaixuan", "1");//筛选
//					map.put("Agrgl", grgl1.toString());
//					map.put("Bgrgl", grgl2.toString());
//					System.out.println(map);
//					System.out.println("grgl1:" +grgl1);
//					System.out.println("grgl2:" +grgl2);
//					System.out.println("aGl:" +aGl);
//					System.out.println("bGl:" +bGl);
					/**
					 * 修改其他map中这两个节点的概率，为了之后的计算
					 */
					for (Map<String, Object> map2 : sjclList) {
						if(DateUtil.dateDiff(DateUtil.MyStringToDate(map2.get("RcontactTime").toString()), new Date())<qfq*24*60*60*1000) {
							if(map.get("AId").toString().equals(map2.get("AId").toString())) {
								map2.put("Agrgl", grgl1.toString());
							}
							if(map.get("AId").toString().equals(map2.get("BId").toString())) {
								map2.put("Bgrgl", grgl1.toString());
							}
							if(map.get("BId").toString().equals(map2.get("AId").toString())) {
								map2.put("Agrgl", grgl2.toString());
							}
							if(map.get("BId").toString().equals(map2.get("BId").toString())) {
								map2.put("Bgrgl", grgl2.toString());
							}
						}
					}
					/**
					 * 修改这次接触之后的 按照时间最近的顺序  以此修改 接触的关系上存的RXgrgl和标志位sfxyjs.
					 */
//					Double grglBefor1 = grgl1;
//					Double grglBefor2 = grgl2;
					Double grglBefor1 = 0.0;
					Double grglBefor2 = 0.0;
					for(Map<String, Object> map3 : sjclList) {
						
						if(DateUtil.dateDiff(DateUtil.MyStringToDate(map.get("RcontactTime").toString()), new Date())<qfq*24*60*60*1000 && 
								(DateUtil.compareDate(map.get("RcontactTime").toString(), map3.get("RcontactTime").toString()))) {
							if(map.get("AId").toString().equals(map3.get("AId").toString()) && 
									(map3.get("Agrgl") == null || Double.parseDouble(map.get("Agrgl").toString()) != 1.0)) {
								dingLiang1(map3);
//								grglBefor1 = 1-(1-grgl1Temp)/(1-(1.0-kz1)*age1*jcNum2*jcbNum1*tfqk*duration*jclx*grgl2Temp);
								grglBefor1 = rAgrgl + rBgrglTemp * pA - rAgrgl * rBgrglTemp * pA;
								map3.put("RAgrgl", grglBefor1.toString());
								map3.put("sfxyjs", "true");
								map3.put("shaixuan", "1");//筛选
							}
							if(map.get("AId").toString().equals(map3.get("BId").toString()) && 
									(map3.get("Bgrgl") == null || Double.parseDouble(map.get("Agrgl").toString()) != 1.0)) {
								dingLiang1(map3);
//								grglBefor1 = 1-(1-grgl2Temp)/(1-(1.0-kz2)*age2*jcNum1*jcbNum2*tfqk*duration*jclx*grgl1Temp);
								grglBefor1 = rBgrgl + rBgrglTemp * pA - rBgrgl * rBgrglTemp * pA;
								map3.put("RBgrgl", grglBefor1.toString());
								map3.put("sfxyjs", "true");
								map3.put("shaixuan", "1");//筛选
							}
							if(map.get("BId").toString().equals(map3.get("AId").toString()) && 
									(map3.get("Agrgl") == null || Double.parseDouble(map.get("Bgrgl").toString()) != 1.0)) {
								dingLiang1(map3);
//								grglBefor2 = 1-(1-grgl1Temp)/(1-(1.0-kz1)*age1*jcNum2*jcbNum1*tfqk*duration*jclx*grgl2Temp);
								grglBefor2 = rAgrgl + rAgrglTemp * pB - rAgrgl * rAgrglTemp * pB;
								map3.put("RAgrgl", grglBefor2.toString());
								map3.put("sfxyjs", "true");
								map3.put("shaixuan", "1");//筛选
							}
							if(map.get("BId").toString().equals(map3.get("BId").toString()) && 
									(map3.get("Bgrgl") == null || Double.parseDouble(map.get("Bgrgl").toString()) != 1.0)) {
								dingLiang1(map3);
//								grglBefor2 = 1- (1-grgl2Temp)/(1-(1.0-kz2)*age2*jcNum1*jcbNum2*tfqk*duration*jclx*grgl1Temp);
								grglBefor2 = rBgrgl + rAgrglTemp * pB - rBgrgl * rAgrglTemp * pB;
								map3.put("RBgrgl", grglBefor2.toString());
								map3.put("sfxyjs", "true");
								map3.put("shaixuan", "1");//筛选
							}
						}
					}
				}	
			}
			
			for(Map<String, Object> map : sjclList) {
//				System.out.println(map);
				if(map.get("shaixuan")!=null && "1".equals(map.get("shaixuan").toString())) {
//					System.out.println(map);
					personRepository.updateP(Long.parseLong(map.get("AId").toString()),
							Long.parseLong(map.get("RId").toString()),
							Long.parseLong(map.get("BId").toString()),
							map.get("Agrgl").toString(),
							map.get("Bgrgl").toString(),map.get("RAgrgl").toString(),
							map.get("RBgrgl").toString(),map.get("sfxyjs").toString());
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.info(e);
			
		}
		
	}
	
	/**
	 * 给影响参数定量
	 * @author 罗穆健
	 * @date 2020年4月22日
	 * @param map
	 */
	protected void dingLiang(Map<String, Object>map) {
		if(map.get("Aage") == null || "".equals(map.get("Aage").toString())) {
			age1 = 0.95;
		} else {
			if(Integer.parseInt(map.get("Aage").toString()) <=10) {
				age1 = 0.98;
			}else if(10 < Integer.parseInt(map.get("Aage").toString())&&
					Integer.parseInt(map.get("Aage").toString()) <=50){
				age1 = 0.95;
			}else {
				age1 = 1.0;
			}
		}
		if(map.get("Bage") == null || "".equals(map.get("Bage").toString())) {
			age2 = 0.95;
		} else {
			if(Integer.parseInt(map.get("Bage").toString()) <=10) {
				age2 = 0.98;
			}else if(10 < Integer.parseInt(map.get("Bage").toString())&&
					Integer.parseInt(map.get("Bage").toString()) <=50){
				age2 = 0.95;
			}else {
				age2 = 1.0;
			}
		}
		
		if(map.get("Agrgl") == null || "".equals(map.get("Agrgl").toString())) {
			grgl1 = 0.0;
			grgl1Temp =0.0;
		}else {
			grgl1 = Double.parseDouble(map.get("Agrgl").toString());
			grgl1Temp = Double.parseDouble(map.get("Agrgl").toString());
		}
		if(map.get("Bgrgl") == null || "".equals(map.get("Bgrgl").toString())) {
			grgl2 = 0.0;
			grgl2Temp =0.0;
		}else {
			grgl2 = Double.parseDouble(map.get("Bgrgl").toString());
			grgl2Temp =Double.parseDouble(map.get("Bgrgl").toString());
		}
		
		if(map.get("AjcNum") == null || "".equals(map.get("AjcNum").toString())) {
			jcNum1 = 1.0;
		}else if(Integer.parseInt(map.get("AjcNum").toString())==0){
			jcNum1 = 1.0;
		}else if(Integer.parseInt(map.get("AjcNum").toString())==1 && grgl1 != 1.0){
			jcNum1 = 0.01;
		}else if(Integer.parseInt(map.get("AjcNum").toString()) > 1 && grgl1 != 1.0){
			jcNum1 = 0.1*Math.pow(0.1,Integer.parseInt(map.get("AjcNum").toString()));
		}else {
			jcNum1 = 1.0;
		}
		if(map.get("BjcNum") == null || "".equals(map.get("BjcNum").toString())) {
			jcNum2 = 1.0;
		}else if(Integer.parseInt(map.get("BjcNum").toString())==0){
			jcNum2 = 1.0;
		}else if(Integer.parseInt(map.get("BjcNum").toString())==1 && grgl2 != 1.0){
			jcNum2 = 0.01;
		}else if(Integer.parseInt(map.get("BjcNum").toString()) > 1 && grgl2 != 1.0){
			jcNum2 = 0.1*Math.pow(0.1,Integer.parseInt(map.get("BjcNum").toString()));
		}else {
			jcNum2 = 1.0;
		}
		
		if(map.get("AjcbNum") == null || "".equals(map.get("AjcbNum").toString())) {
			jcbNum1 = 0.75;
		}else {
			jcbNum1 =0.75 + 0.05 * Double.parseDouble(map.get("AjcbNum").toString());
		}
		if(map.get("BjcbNum") == null || "".equals(map.get("BjcbNum").toString())) {
			jcbNum2 = 0.75;
		}else {
			jcbNum2 =0.75 + 0.05 * Double.parseDouble(map.get("BjcbNum").toString());
		}
		
		if(map.get("Rtfqk") == null || "".equals(map.get("Rtfqk").toString())) {
			tfqk = 0.5;
		}else if("shiwai".equals(map.get("Rtfqk").toString())){
			tfqk = 0.3;
		}else if("sntflh".equals(map.get("Rtfqk").toString())){
			tfqk = 0.5;
		}else if("sntfjc".equals(map.get("Rtfqk").toString())){
			tfqk = 0.9;
		}else{
			tfqk = 1.0;
		}
		
		if(map.get("Rduration") == null || "".equals(map.get("Rduration").toString())) {
			duration = 0.5;
		}else {
			duration = 0.3 + 0.7/120 * Double.parseDouble(map.get("Rduration").toString());
			if(duration >= 1.0) {
				duration = 1.0;
			}
		}
		if(map.get("RcontactName") == null || "".equals(map.get("RcontactName").toString())) {
			jclx = 0.5;
		}else if("common".equals(map.get("RcontactName").toString())){
			jclx = 0.3;
		}else if("talk".equals(map.get("RcontactName").toString())){
			jclx = 0.85;
		}else if("handshake".equals(map.get("RcontactName").toString())){
			jclx = 0.8;
		}else if("embrace".equals(map.get("RcontactName").toString())){
			jclx = 0.9;
		}else {
			jclx = 1.0;
		}
		
		if(map.get("Rkzqk") == null || "".equals(map.get("Rkzqk").toString())) {
			kz1 = 0.5;
		}else if("bkz".equals(map.get("Rkzqk").toString())){
			kz1 = 0.3;
		}else if("n95".equals(map.get("Rkzqk").toString())){
			kz1 = 0.95;
		}else if("kn99".equals(map.get("Rkzqk").toString())){
			kz1 = 0.99;
		}else if("qtkz".equals(map.get("Rkzqk").toString())){
			kz1 = 0.5;
		}else {
			kz1 = 0.0;
		}
		if(map.get("Rdfkz") == null || "".equals(map.get("Rdfkz").toString())) {
			kz2 = 0.5;
		}else if("bkz".equals(map.get("Rdfkz").toString())){
			kz2 = 0.3;
		}else if("n95".equals(map.get("Rdfkz").toString())){
			kz2 = 0.95;
		}else if("kn99".equals(map.get("Rdfkz").toString())){
			kz2 = 0.99;
		}else if("qtkz".equals(map.get("Rdfkz").toString())){
			kz2 = 0.5;
		}else {
			kz2 = 0.0;
		}
		
		if(map.get("RAgrgl") == null || "".equals(map.get("RAgrgl").toString())) {
			map.put("RAgrgl",grgl1Temp);
			rAgrgl = grgl1Temp;
		} else {
			rAgrgl = Double.parseDouble(map.get("RAgrgl").toString());
		}
		if(map.get("RBgrgl") == null || "".equals(map.get("RBgrgl").toString())) {
			map.put("RBgrgl",grgl2Temp);
			rBgrgl = grgl2Temp;
		} else {
			rBgrgl = Double.parseDouble(map.get("RBgrgl").toString());
		}
		if("true".equals(map.get("sc").toString())) {
			kz1 = 1.0;
			kz2 = 1.0;
		}
	}
	
	/**
	 * 处理超出潜伏期的节点的概率
	 * 目前只是把未确诊的节点概率置为0，未做其他处理
	 * @author 罗穆健
	 * @throws ParseException 
	 * @date 2020年5月1日
	 */
	public void clccqfq(){
		List<Map<String, Object>> sjclList = new ArrayList<Map<String,Object>>();
		sjclList = personRepository.getAllPersonNoQz1();
		sjclList.addAll(personRepository.getAllPersonNoQz2());
		ListUtil.ListSortId(sjclList, "id");
		List<Long> xycList = new ArrayList<Long>();
		for (Map<String, Object> map : sjclList) {
			map.put("flag", "2");
		}
		try {
			for (Map<String, Object> map1 : sjclList) {
				Boolean flag = false;
				if("2".equals(map1.get("flag").toString())) {
					for (Map<String, Object> map2 : sjclList) {
						if("2".equals(map2.get("flag").toString())) {
							if(map1.get("id").toString().equals(map2.get("id").toString())) {
								map2.put("flag", "1");		
								if((DateUtil.dateDiff(DateUtil.MyStringToDate(map2.get("contactTime").toString()),
										new Date()) <= qfq*24*60*60*1000)) {
									flag = true;
								}
							}
						}
					}
					if(!flag) {
						xycList.add(Long.parseLong(map1.get("id").toString()));
					}
				}
			}
			
			for (Long id : xycList) {
				personRepository.updatePerson(id);
			}
		} catch (Exception e) {
			// TODO: handle exception
			logger.info(e);
		}
	}
	
	protected void dingLiang1(Map<String, Object>map) {
		if(map.get("Aage") == null || "".equals(map.get("Aage").toString())) {
			age1 = 0.95;
		} else {
			if(Integer.parseInt(map.get("Aage").toString()) <=10) {
				age1 = 0.98;
			}else if(10 < Integer.parseInt(map.get("Aage").toString())&&
					Integer.parseInt(map.get("Aage").toString()) <=50){
				age1 = 0.95;
			}else {
				age1 = 1.0;
			}
		}
		if(map.get("Bage") == null || "".equals(map.get("Bage").toString())) {
			age2 = 0.95;
		} else {
			if(Integer.parseInt(map.get("Bage").toString()) <=10) {
				age2 = 0.98;
			}else if(10 < Integer.parseInt(map.get("Bage").toString())&&
					Integer.parseInt(map.get("Bage").toString()) <=50){
				age2 = 0.95;
			}else {
				age2 = 1.0;
			}
		}
		
		if(map.get("Agrgl") == null || "".equals(map.get("Agrgl").toString())) {
			grgl1 = 0.0;
			grgl1Temp =0.0;
		}else {
			grgl1 = Double.parseDouble(map.get("Agrgl").toString());
			grgl1Temp = Double.parseDouble(map.get("Agrgl").toString());
		}
		if(map.get("Bgrgl") == null || "".equals(map.get("Bgrgl").toString())) {
			grgl2 = 0.0;
			grgl2Temp =0.0;
		}else {
			grgl2 = Double.parseDouble(map.get("Bgrgl").toString());
			grgl2Temp =Double.parseDouble(map.get("Bgrgl").toString());
		}
		
		if(map.get("AjcNum") == null || "".equals(map.get("AjcNum").toString())) {
			jcNum1 = 1.0;
		}else if(Integer.parseInt(map.get("AjcNum").toString())==0){
			jcNum1 = 1.0;
		}else if(Integer.parseInt(map.get("AjcNum").toString())==1 && grgl1 != 1.0){
			jcNum1 = 0.01;
		}else if(Integer.parseInt(map.get("AjcNum").toString()) > 1 && grgl1 != 1.0){
			jcNum1 = 0.1*Math.pow(0.1,Integer.parseInt(map.get("AjcNum").toString()));
		}else {
			jcNum1 = 1.0;
		}
		if(map.get("BjcNum") == null || "".equals(map.get("BjcNum").toString())) {
			jcNum2 = 1.0;
		}else if(Integer.parseInt(map.get("BjcNum").toString())==0){
			jcNum2 = 1.0;
		}else if(Integer.parseInt(map.get("BjcNum").toString())==1 && grgl2 != 1.0){
			jcNum2 = 0.01;
		}else if(Integer.parseInt(map.get("BjcNum").toString()) > 1 && grgl2 != 1.0){
			jcNum2 = 0.1*Math.pow(0.1,Integer.parseInt(map.get("BjcNum").toString()));
		}else {
			jcNum2 = 1.0;
		}
		
		if(map.get("AjcbNum") == null || "".equals(map.get("AjcbNum").toString())) {
			jcbNum1 = 0.75;
		}else {
			jcbNum1 =0.75 + 0.05 * Double.parseDouble(map.get("AjcbNum").toString());
		}
		if(map.get("BjcbNum") == null || "".equals(map.get("BjcbNum").toString())) {
			jcbNum2 = 0.75;
		}else {
			jcbNum2 =0.75 + 0.05 * Double.parseDouble(map.get("BjcbNum").toString());
		}
		
		if(map.get("Rtfqk") == null || "".equals(map.get("Rtfqk").toString())) {
			tfqk = 0.5;
		}else if("shiwai".equals(map.get("Rtfqk").toString())){
			tfqk = 0.3;
		}else if("sntflh".equals(map.get("Rtfqk").toString())){
			tfqk = 0.5;
		}else if("sntfjc".equals(map.get("Rtfqk").toString())){
			tfqk = 0.9;
		}else{
			tfqk = 1.0;
		}
		
		if(map.get("Rduration") == null || "".equals(map.get("Rduration").toString())) {
			duration = 0.5;
		}else {
			duration = 0.3 + 0.7/120 * Double.parseDouble(map.get("Rduration").toString());
			if(duration >= 1.0) {
				duration = 1.0;
			}
		}
		if(map.get("RcontactName") == null || "".equals(map.get("RcontactName").toString())) {
			jclx = 0.5;
		}else if("common".equals(map.get("RcontactName").toString())){
			jclx = 0.3;
		}else if("talk".equals(map.get("RcontactName").toString())){
			jclx = 0.85;
		}else if("handshake".equals(map.get("RcontactName").toString())){
			jclx = 0.8;
		}else if("embrace".equals(map.get("RcontactName").toString())){
			jclx = 0.9;
		}else {
			jclx = 1.0;
		}
		
		if(map.get("Rkzqk") == null || "".equals(map.get("Rkzqk").toString())) {
			kz1 = 0.5;
		}else if("bkz".equals(map.get("Rkzqk").toString())){
			kz1 = 0.3;
		}else if("n95".equals(map.get("Rkzqk").toString())){
			kz1 = 0.95;
		}else if("kn99".equals(map.get("Rkzqk").toString())){
			kz1 = 0.99;
		}else if("qtkz".equals(map.get("Rkzqk").toString())){
			kz1 = 0.5;
		}else {
			kz1 = 0.0;
		}
		if(map.get("Rdfkz") == null || "".equals(map.get("Rdfkz").toString())) {
			kz2 = 0.5;
		}else if("bkz".equals(map.get("Rdfkz").toString())){
			kz2 = 0.3;
		}else if("n95".equals(map.get("Rdfkz").toString())){
			kz2 = 0.95;
		}else if("kn99".equals(map.get("Rdfkz").toString())){
			kz2 = 0.99;
		}else if("qtkz".equals(map.get("Rdfkz").toString())){
			kz2 = 0.5;
		}else {
			kz2 = 0.0;
		}
		
		if(map.get("RAgrgl") == null || "".equals(map.get("RAgrgl").toString())) {
//			map.put("RAgrgl",grgl1Temp);
			rAgrgl = 0.0;
		} else {
			rAgrgl = Double.parseDouble(map.get("RAgrgl").toString());
		}
		if(map.get("RBgrgl") == null || "".equals(map.get("RBgrgl").toString())) {
//			map.put("RBgrgl",grgl2Temp);
			rBgrgl = 0.0;
		} else {
			rBgrgl = Double.parseDouble(map.get("RBgrgl").toString());
		}
		if("true".equals(map.get("sc").toString())) {
			kz1 = 1.0;
			kz2 = 1.0;
		}
	}
}
